import process from 'node:process';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { release } from 'node:os';
import { app } from 'electron';

const __dirname = import.meta.dirname || dirname(fileURLToPath(import.meta.url));

process.env.DIST_ELECTRON = __dirname;
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist');
process.env.PUBLIC = import.meta.env.DEV ? join(__dirname, '../public') : process.env.DIST_ELECTRON;

// Disable GPU Acceleration for Windows 7
if (release().startsWith('6.1')) app.disableHardwareAcceleration();

// Set application name for Windows 10+ notifications
if (process.platform === 'win32') app.setAppUserModelId(app.getName());

if (!app.requestSingleInstanceLock()) {
  app.quit();
  process.exit(0);
}

// Remove electron security warnings
// This warning only shows in development mode
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
